package com.example.boot07.Controller;

import com.example.boot07.entity.Person;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Name: helloAxiosContrller
 * @Author: 西风残叶
 * @Company: 朝兮网络工作室
 * @Data: 2023/11/12 15:30
 */
@RestController
public class helloAxiosContrller {
    @RequestMapping("/helloAxios")
    public String helloAxios(String name,Integer age) {
        return "服务器接收到了请求! name = "+name+", age = "+age;
    }
    // 如果客户端发出的时post请求,并且参数是自定义的JS对象
    // 服务器接收参数是需要同样自定义一个对象来接收,并且通过@RequestBody注解修饰
    @RequestMapping("/postAxios")
    public String postAxios(@RequestBody Person person){
        return "测试成功!"+person.toString();
    }
}
